import java.util.ArrayList;


public class Commande {
	private int numCommande;
	private ArrayList<LigneCommande> lignes;
	private double totalMontant;
	private Client cl;
	
	public Commande(){
		numCommande = 0;
		lignes  = new ArrayList<LigneCommande>();
		totalMontant = 0;
		cl = new Client("nom", "prenom", 12, "email@");
	}
	
	

	public Commande(int numCommande, Client cl) {
		this.numCommande = numCommande;
		this.cl = cl;
	}
	
	public Client getClient(){
		return cl;
	}
	
	public void setClient(Client cl){
		if (cl.getNom()=="" || cl.getPrenom()=="" || cl.getAge()<0 || !cl.getEmail().contains("@"))
			System.err.println("Client invalide");
		else
			this.cl = cl;
	}

	public int getNumCommande() {
		return numCommande;
	}

	public void setNumCommande(int numCommande) {
		if(numCommande < 0 )
			System.err.println("Numero invalide");
		else
			this.numCommande = numCommande;
		
	}

	public ArrayList<LigneCommande> getLignes() {
		return lignes;
	}

	public void addLigne(LigneCommande ligne) {
		lignes.add(ligne);
		totalMontant += ligne.getTotal();
	}
	
	public void total(){
		for (int i = 0; i < lignes.size(); i++) {
			totalMontant += lignes.get(i).getTotal();
		}
	}
	public void setMontant(double m){
		if (m<0)
			System.err.println("Montant invalide");
		else
			totalMontant = m;
	}

	public double getMontant() {
		return totalMontant;
	}
	
	
}
